import React, { PureComponent } from 'react'

export class CountClass extends PureComponent {
  constructor() {
    super()
    this.state = {
      count: 0
    }
  }
  changeCount(val) {
    this.setState({
      count: this.state.count + val
    })
  }
  render() {
    const { count } = this.state
    return (
      <div>
        <div>类组件</div>
        <div>当前计数: { count }</div>
        <button onClick={e => this.changeCount(1)}>+1</button>
        <button onClick={e => this.changeCount(-1)}>-1</button>
      </div>
    )
  }
}

export default CountClass